
const defaultState = {
    homeArticles:[],
    homeTopicImages:[],
    homeLunBoImages:[],
    authorList:[],
    hasNextPage:false,
    page:1
}
export default (state = defaultState,action) => {
    switch (action.type) {
        case "GET_HOME_DATA_INFO":
            state.homeArticles=action.homeArticles;
            state.homeTopicImages=action.homeTopicImages;
            state.homeLunBoImages=action.homeLunBoImages;   
            return {...state}
        case "GET_NEXT_PAGE":
            state.page = action.index +1;
            state.hasNextPage = action.hasNextPage;
            state.homeArticles = state.homeArticles.concat(action.data.author)
            // console.log('state.hasNextPage--',state.hasNextPage)
            return {...state}
        case "GET_ARTICLE_DATA":
            console.log("action",action)
            // console.log("action.index",action.index)
            // console.log("action.hasNextPage",action.hasNextPage)
            state.homeArticles = state.homeArticles.concat( action.data.homeArticles);
            if(action.data.page && action.data.page.total && action.data.page.total > state.homeArticles.length){
                state.hasNextPage = true;
                state.page = action.index+1;
            }
            console.log("state.page====",state.page)
            return {...state}
        case "GET_TOPICE_DATA":
            state.homeTopicImages =action.data;
            return {...state}
        case "GET_AUTHOR_DATA":
            state.authorList = action.data.author;
            return {...state}
        case "GET_LUNBO_IMAGE":
            state.homeLunBoImages = action.data;
            return {...state}
        default:
            return{...state}
    }
}